#调整数据尺度
# from sklearn.preprocessing import MinMaxScaler
# from numpy import set_printoptions
# from pandas import read_csv
# filename = 'pima_data.csv'
# names = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class']
# data = read_csv(filename, names=names)
# array = data.values
# X = array[:, 0:8]
# Y = array[:, 8]
# transformer = MinMaxScaler(feature_range=(0, 1))
# newX = transformer.fit_transform(X)
# set_printoptions(precision=3)
# print(newX)
#正态化
# from sklearn.preprocessing import StandardScaler
# from numpy import set_printoptions
# from pandas import read_csv
# filename = 'pima_data.csv'
# names = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class']
# data = read_csv(filename, names=names)
# array = data.values
# X = array[:, 0:8]
# Y = array[:, 8]
# transformer = StandardScaler().fit(X)
# newX = transformer.transform(X)
# set_printoptions(precision=3)
# print(newX)
#标准化处理
# from sklearn.preprocessing import Normalizer
# from numpy import set_printoptions
# from pandas import read_csv
# filename = 'pima_data.csv'
# names = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class']
# data = read_csv(filename, names=names)
# array = data.values
# X = array[:, 0:8]
# Y = array[:, 8]
# transformer = Normalizer().fit(X)
# newX = transformer.transform(X)
# set_printoptions(precision=3)
# print(newX)
#二值数据
from sklearn.preprocessing import Binarizer
from numpy import set_printoptions
from pandas import read_csv
filename = 'pima_data.csv'
names = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class']
data = read_csv(filename, names=names)
array = data.values
X = array[:, 0:8]
Y = array[:, 8]
transformer = Binarizer(threshold=0.0).fit(X)
newX = transformer.transform(X)
set_printoptions(precision=3)
print(newX)